home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* Procedure to receive random strings from tnc *)
- (* *)
- (* Copyright 1988, 1991 by H. Roy Engehausen. All rights reserved. *)
- (* This software may be freely distributed and used, but it may not *)
- (* under any circumstances be sold by anyone other than the author. *)
- (* It may be distributed by a commercial company as long as it is *)
- (* for no cost. *)
- (* *)
- (*===========================================================================*)
-
- FUNCTION garbage_collect_tnc : STRING;
-
- VAR
- i : BYTE;
- int_no : BYTE;
- tnc_registers : REGISTERS;
- result : STRING;
-
- BEGIN;
-
- WITH active_port^, tnc_registers DO
-
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* No garbage on these TNCs *)
- (*-------------------------------------------------------------------*)
-
- IF (port_type = port_pc1xx) OR (port_type = port_bpqhost) THEN
- BEGIN;
- garbage_collect_tnc := '';
- EXIT;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Get ready for loop *)
- (*-------------------------------------------------------------------*)
-
- i := 0;
- int_no := active_port^.com_number;
-
- (*-------------------------------------------------------------------*)
- (* Perform the initial RECEIVE DATA AVAILABLE test. Assumed true *)
- (* for the PC*PA adapter *)
- (*-------------------------------------------------------------------*)
-
- IF (port_type <> port_pcpa) THEN
- BEGIN;
- AX := $0300;
- DX := com_number - 1;
-
- INTR(tnc_interrupt, tnc_registers);
-
- AH := AH AND lsr_8250_dr;
- END
- ELSE
- AH := 1;
-
- (*-------------------------------------------------------------------*)
- (* Loop while data is available and the data count is acceptable *)
- (*-------------------------------------------------------------------*)
-
- WHILE (AH <> 0) AND (i < 128) DO
- BEGIN;
-
- i := i + 1;
-
- IF port_type <> port_pcpa THEN
- BEGIN;
- AX := $0200;
- DX := com_number - 1;
-
- INTR(tnc_interrupt, tnc_registers);
- END
- ELSE
- BEGIN;
-
- AX := 0;
- INTR(int_no, tnc_registers);
-
- END;
-
- {$IFDEF wa8debug}
- WRITE('.',CHR(AL), AL);
- {$ENDIF}
-
- result[i] := CHR(AL);
-
-
- IF port_type <> port_pcpa THEN
- AH := AH AND lsr_8250_dr
- ELSE
- IF AH = 0 THEN
- DEC(i);
-
- END;
-
- (*-------------------------------------------------------------------*)
- (* Set the result and exit *)
- (*-------------------------------------------------------------------*)
-
- result[0] := CHR(i);
-
- garbage_collect_tnc := result;
-
- END;
-
- END;